﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MutiCodecO.codeclib
{
    class Asii2Num : ICodec
    {
        public String parse(String strInput)
        {
            byte[] bytesInput = Encoding.Default.GetBytes(strInput);
            StringBuilder strRslt = new StringBuilder();
            for (int i = 0; i < bytesInput.Length; i++)
            {
                strRslt.Append(Convert.ToInt32(bytesInput[i]).ToString());
                if (i != bytesInput.Length - 1)
                    strRslt.Append(',');
            }
            return strRslt.ToString();
        }

        public String parse(String strInput, String prefix, String partion)
        {
            byte[] bytesInput = Encoding.Default.GetBytes(strInput);
            StringBuilder strRslt = new StringBuilder();
            for (int i = 0; i < bytesInput.Length; i++)
            {
                strRslt.Append(prefix);
                strRslt.Append(Convert.ToInt32(bytesInput[i]).ToString());
                if (i != bytesInput.Length - 1)
                    strRslt.Append(partion);
            }
            return strRslt.ToString();
        }
    }
}
